package com.pattern.command.tenant;

import com.pattern.command.frame.Command;
import com.pattern.command.third.Service2;

public class Command2 implements Command {
    private String orderName; // inParam
    private int orderId;      // outParam

    public int getOrderId() {
        return orderId;
    }

    public Command2(String orderName) {
        this.orderName = orderName;
    }

    @Override
    public boolean execute() {
        int id = Service2.createOrder(orderName);
        if(id<0) {
            return false;
        }
        orderId = id;
        return true;
    }

    @Override
    public boolean undo() {
        return Service2.deleteOrder(orderId);
    }
}
